package com.zzyl.nursing.controller.member;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.dto.WechatProjectPageDto;
import com.zzyl.serve.domain.NursingProject;
import com.zzyl.serve.service.INursingProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.zzyl.common.core.domain.R.ok;

/**
 * 小程序预约参观功能
 *
 * @author I:P Masquerenaʚїɞ
 * @date 2025/6/9
 */
@RestController
@RequestMapping("member/orders/project")
@Api(tags = "小程序预约参观功能")
@RequiredArgsConstructor
public class MemberOrderController extends BaseController {
    private final INursingProjectService nursingProjectService;

    /**
     * 小程序端获取服务列表
     *
     * @author I:P Masquerenaʚїɞ
     * @date 2025/6/9
     */
    @GetMapping("page")
    @ApiOperation(value = "获取护理项目列表")
    public TableDataInfo<List<NursingProject>> list(WechatProjectPageDto wechatProjectPageDto)
    {
        // 下面这个方法自动读取 wechatProjectPageDto 中的 pageNum 和 pageSize
        startPage();
        NursingProject nursingProject = BeanUtil.copyProperties(wechatProjectPageDto, NursingProject.class);
        List<NursingProject> list = nursingProjectService.selectNursingProjectList(nursingProject);
        return getDataTable(list);
    }

    /**
     * 小程序端获取服务详情
     *
     * @author I:P Masquerenaʚїɞ
     * @date 2025/6/9
     */
    @GetMapping( "{id}")
    @ApiOperation("获取护理项目详细信息")
    public R<NursingProject> getInfo(@PathVariable("id") Long id)
    {
        return ok(nursingProjectService.selectNursingProjectById(id));
    }
}
